package cn.kgc.mushroomdatabaseprovider.controller;

import cn.kgc.mushroomcommon.pojo.ResultEntity;
import cn.kgc.mushroomcommon.pojo.Shoppingcar;
import cn.kgc.mushroomcommon.pojo.User;
import cn.kgc.mushroomdatabaseprovider.service.ShoppingcarService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/database/provider/shoppingcar")
public class ShoppingCarController {
    @Resource
    ShoppingcarService shoppingcarService;

    @RequestMapping("/query/shoppingcar/list")
    public List<Shoppingcar> selectShoppingCarList(){
        return shoppingcarService.selectShoppingCarList();
    }


    @RequestMapping("/batch/remove")
    public Integer batchRemove(@RequestBody List<Integer> shoppingCarIdList) {
        return shoppingcarService.batchRemove(shoppingCarIdList);
    }

    @RequestMapping("/query/shoppingcar/list/by/id/list")
    public List<Shoppingcar> getShoppingCarListByIdList(@RequestBody List<Integer> shoppingCarIdList) {
        return shoppingcarService.getShoppingCarListByIdList(shoppingCarIdList);
    }


    @RequestMapping("/addShopCar")
    public ResultEntity<String> addShopCar(@RequestBody Shoppingcar shoppingcar) {
        int i = shoppingcarService.addShopCar(shoppingcar);
        if (i == 0) {
            return ResultEntity.failed("添加失败");
        }
        return ResultEntity.successNoData();
    }
}
